82651a
@@ -27,7 +27,6 @@
import org.springframework.aop.scope.ScopedProxyFactoryBean;
 import org.springframework.asm.Type;
 import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.beans.factory.DisposableBean;
 import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
 import org.springframework.beans.factory.support.SimpleInstantiationStrategy;
@@ -65,9 +64,9 @@
import org.springframework.util.ReflectionUtils;
  */
 class ConfigurationClassEnhancer {
 
+	// The callbacks to use. Note that these callbacks must be stateless.
 	private static final Callback[] CALLBACKS = new Callback[] {
 			new BeanMethodInterceptor(),
-			new DisposableBeanMethodInterceptor(),
 			new BeanFactoryAwareMethodInterceptor(),
 			NoOp.INSTANCE
 	};
@@ -139,15 +138,13 @@
class ConfigurationClassEnhancer {
 	 * Facilitates idempotent behavior for {@link ConfigurationClassEnhancer#enhance(Class)}
 	 * through checking to see if candidate classes are already assignable to it, e.g.
 	 * have already been enhanced.
-	 * <p>Also extends {@link DisposableBean} and {@link BeanFactoryAware}, as all
-	 * enhanced {@code @Configuration} classes require access to the {@link BeanFactory}
-	 * that created them and must de-register static CGLIB callbacks on destruction,
-	 * which is handled by the (private) {@code DisposableBeanMethodInterceptor}.
+	 * <p>Also extends {@link BeanFactoryAware}, as all enhanced {@code @Configuration}
+	 * classes require access to the {@link BeanFactory} that created them.
 	 * <p>Note that this interface is intended for framework-internal use only, however
 	 * must remain public in order to allow access to subclasses generated from other
 	 * packages (i.e. user code).
 	 */
-	public interface EnhancedConfiguration extends DisposableBean, BeanFactoryAware {
+	public interface EnhancedConfiguration extends BeanFactoryAware {
 	}
 
 
@@ -403,32 +400,4 @@
class ConfigurationClassEnhancer {
 		}
 	}
 
-
-	/**
-	 * Intercepts the invocation of any {@link DisposableBean#destroy()} on @Configuration
-	 * class instances for the purpose of de-registering CGLIB callbacks. This helps avoid
-	 * garbage collection issues. See SPR-7901.
-	 * @see EnhancedConfiguration
-	 */
-	private static class DisposableBeanMethodInterceptor implements MethodInterceptor, ConditionalCallback {
-
-		@Override
-		public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
-			Enhancer.registerStaticCallbacks(obj.getClass(), null);
-			// Does the actual (non-CGLIB) superclass actually implement DisposableBean?
-			// If so, call its dispose() method. If not, just exit.
-			if (DisposableBean.class.isAssignableFrom(obj.getClass().getSuperclass())) {
-				return proxy.invokeSuper(obj, args);
-			}
-			return null;
-		}
-
-		@Override
-		public boolean isMatch(Method candidateMethod) {
-			return candidateMethod.getName().equals("destroy") &&
-					candidateMethod.getParameterTypes().length == 0 &&
-					DisposableBean.class.isAssignableFrom(candidateMethod.getDeclaringClass());
-		}
-	}
-
 }
